-
Notifications
You must be signed in to change notification settings - Fork 0
MPC consolidation #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3f959f5 to
87d9bd8
Compare
pranavjain97
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall lgtm; small nits
| throw new Error('consolidateAddresses must be an array of addresses'); | ||
| } | ||
|
|
||
| const isMPC = wallet._wallet.multisigType === 'tss'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const isMPC = wallet._wallet.multisigType === 'tss'; | |
| const isMPC = wallet.multisigType() === 'tss'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| msg = `Consolidations failed: ${failedTxs.length} and succeeded: ${successfulTxs.length}`; | ||
| } else { | ||
| // All failed | ||
| status = 400; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a 500. 400 is if it fails due to an error from user input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the account consolidation flow to support both onchain multisig and MPC (TSS) wallets, introduces a commonKeychain parameter, and updates the API spec and tests.
- Add optional
commonKeychainto the ConsolidateRequest spec and validate it in handlerUtils. - Refactor
handleConsolidateto loop through builds, collect per-build success/failure, and branch betweensendAccountConsolidationandsignAndSendTxRequests. - Export
signAndSendMultisig, update API JSON (masterBitgoExpress.json) with a newaccelerateendpoint, and adapt tests for the new consolidation logic.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/api/master/routers/masterApiSpec.ts | Added commonKeychain as an optional field in ConsolidateRequest |
| src/api/master/handlers/handleSendMany.ts | Made signAndSendMultisig an exported function |
| src/api/master/handlers/handleConsolidate.ts | Complete overhaul to handle MPC vs. multisig consolidation and result handling |
| src/api/master/handlerUtils.ts | Extended getWalletAndSigningKeychain to accept and validate commonKeychain |
| src/tests/api/master/consolidate.test.ts | Updated and expanded tests for both multisig and MPC consolidation flows |
| masterBitgoExpress.json | Added /accelerate endpoint and included commonKeychain in spec |
Comments suppressed due to low confidence (5)
src/api/master/handlerUtils.ts:20
- Update the JSDoc/comments for
getWalletAndSigningKeychainto describe the newcommonKeychainparameter and its purpose.
params: { source: 'user' | 'backup'; pubkey?: string; commonKeychain?: string };
src/tests/api/master/consolidate.test.ts:12
- The test suite title references
consolidateunspentsbut the endpoint under test is/consolidate; please correct the describe string to match the actual route.
describe('POST /api/:coin/wallet/:walletId/consolidateunspents', () => {
src/api/master/handlers/handleConsolidate.ts:38
- [nitpick] The request spec marks
consolidateAddressesas optional, but this validation rejects undefined values. Decide whether missing addresses should default to full consolidation or update the spec to make it required.
throw new Error('consolidateAddresses must be an array of addresses');
masterBitgoExpress.json:9
- [nitpick] The new
accelerateendpoint appears unrelated to MPC consolidation; consider splitting it into its own PR or providing additional context.
"/api/{coin}/wallet/{walletId}/accelerate": {
src/api/master/handlers/handleSendMany.ts:195
- [nitpick] The
signAndSendMultisigfunction was made exported but isn’t referenced elsewhere; remove the export if it’s unused or update imports to leverage it where appropriate.
export async function signAndSendMultisig(
mohammadalfaiyazbitgo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please address comments in a follow up.
| (error as any).result = { | ||
| success: successfulTxs, | ||
| failure: failedTxs, | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please avoid any when you can.
MPC consolidation
TASK: WP-5170